Skip to content

Conversation

@codesungrape
Copy link
Collaborator

Description

This PR introduces a new user-facing front-end to display the list of books, built with GOV.UK Frontend styles. It establishes the front-end build pipeline and creates a new web page that fetches and displays paginated data from the existing /books API endpoint.

This work also standardizes the project's Python version using pyenv to ensure a consistent development environment for all contributors.

Fixes # (issue number if applicable)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Manually tested by running the application (make run) and navigating to /show-books. Verified that:
    • The page loads with GOV.UK styling.
    • The book list appears correctly.
    • The "Showing books 1-20 of X" count is accurate.
    • The "Next" and "Previous" pagination links work and fetch the correct data.
  • Added new automated tests (tests/routes/test_web_routes.py) that verify the Flask route renders the correct template with a 200 OK status. Test coverage for web_routes.py is now 100%.
  • All existing tests pass locally (make test).

Please describe how to test the changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My individual commit messages are descriptive and follow our commit guidelines
  • I have made corresponding changes to the documentation (README.md)
  • My changes generate no new warnings
  • I have added tests that prove my feature works
  • New and existing unit tests pass locally with my changes

@codesungrape codesungrape requested a review from Copilot October 2, 2025 18:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new user-facing front-end to display the list of books, built with GOV.UK Frontend styles. It establishes the front-end build pipeline and creates a new web page that fetches and displays paginated data from the existing /books API endpoint. The changes also standardize the project's Python version using pyenv to ensure a consistent development environment for all contributors.

  • Adds a complete GOV.UK Frontend component library for styling
  • Creates a new /show-books route with JavaScript-powered pagination
  • Standardizes Python version management using pyenv

Reviewed Changes

Copilot reviewed 84 out of 2399 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/templates/govuk/ Complete GOV.UK Frontend component library including accordion, breadcrumbs, buttons, etc.
app/templates/books.html New front-end page displaying books in a table with pagination
app/routes/web_routes.py New Flask blueprint for web routes serving the books page
app/scss/main.scss SCSS entry point importing GOV.UK Frontend styles
.python-version Specifies Python 3.12.0 for consistent development environment
README.md Updated setup instructions to include pyenv usage
Makefile Enhanced to work with pyenv virtual environment creation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

})
.catch(error => {
console.error('Error fetching books: ', error);
container.innerHTML = '<div class="govuk-error-message">...</div>';
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message displayed to users is not informative. Replace the placeholder "..." with a proper error message like "Unable to load books. Please try again later."

Suggested change
container.innerHTML = '<div class="govuk-error-message">...</div>';
container.innerHTML = '<div class="govuk-error-message">Unable to load books. Please try again later.</div>';

Copilot uses AI. Check for mistakes.
// Good practice to separate the rendering logic from the fetching logic
function renderTable(data) {

const totalCount = data.total_count || 0
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon at the end of the line. JavaScript should consistently use semicolons for statement termination to follow best practices and maintain consistency with the rest of the codebase.

Suggested change
const totalCount = data.total_count || 0
const totalCount = data.total_count || 0;

Copilot uses AI. Check for mistakes.
// --- MAIN FUNCTION: Fetches and displays a page of books
function loadPage(pageNumber) {

currentPage = pageNumber; //Update the global state
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Comment style is inconsistent. Use consistent spacing with either // Update the global state or follow the established comment style in the file.

Suggested change
currentPage = pageNumber; //Update the global state
currentPage = pageNumber; // Update the global state

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants